 %include header libraryName=libraryName
    <script type="text/javascript">
        //<!--
        $(document).ready(function() {
            $('.checkAll').click(function() {
                var checked = $(this).attr('checked');
                $('.labelCheckbox').attr('checked', checked);
            });
            
            $('input[type=checkbox]').click(function() {
                $('.numSelected').text($('.labelCheckbox:checked').length);
            });
            
            $('.numSelected').text($('.labelCheckbox:checked').length); // In case they refreshed the page or something
        });
        
        function generateLabels() {
            var codes = [];
            $('.labelCheckbox:checked').each(function() {
                codes.push({code: parseInt($(this).parents('tr').find('.id').text(), 10),
                             data: $(this).parents('tr').find('.title').text()});
            });
            window.location = '/administration/generateLabels.pdf?ids=' + encodeURIComponent(JSON.stringify(codes)) + '';
        }
        //-->
    </script>
    <h2>Select Which Resource Labels to Print (<span class="numSelected">0</span> selected)</h2>
    
    <a href="/administration">Administration Home</a>
    <div class="bordered">
        <div><button onclick="generateLabels()">Generate Labels</button></div>
        <table width="100%">
            <thead>
                <tr>
                    <th><input type="checkbox" class="checkAll" /></th>
                    <th>ID</th>
                    <th>ISBN</th>
                    <th>Title</th>
                    <th>Author</th>
                    <th>Publisher</th>
                    <th>Type</th>
                </tr>
            </thead>
            <tbody>
            %for i, resource in zip(range(len(resources)), resources):
                <tr>
                  <td><input type="checkbox" class="labelCheckbox" /></td>
                  <td class="id">{{resource.get('id')}}</td>
                  <td>{{resource.get('isbn')}}</td>
                  <td class="title">{{resource.get('title', '').encode('utf-8')}}</td>
                  <td>{{resource.get('author', '').encode('utf-8')}}</td>
                  <td>{{resource.get('publisher', '').encode('utf-8')}}</td>
                  <td>{{resourceTypes[resource.get('resource_type_id', '')].encode('utf-8')}}</td>
                </tr>
            %end
            </tbody>
        </table>
        <div><button onclick="generateLabels()">Generate Labels</button></div>
        <div><a href="/logout">Logout</a></div>
    </div>
%include footer